package com.bmth.alise.client.utils;

import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class URIUtil {
	final static Pattern p = Pattern.compile(".*\\.([\\w\\d]+\\.[\\w\\d]+)");

	public static String getFirstLevelDomain(String url) {
		try {
			String host = new URL(url).getHost();
			Matcher matcher = p.matcher(host);
			return matcher.find() ? matcher.group(1) : "";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
